home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2694 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Streams
  5. Date: 23 Jan 1996 04:27:03 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Jan22212703@qcd.lanl.gov>
  8. References: <4e0lp3$lkf@nic.wat.hookup.net>
  9. NNTP-Posting-Host: qcd.lanl.gov
  10. Mime-Version: 1.0
  11. Content-Type: text
  12. In-reply-to: xenon@the-fix.sos.on.ca's message of Mon, 22 Jan 1996 18:27:41 GMT
  13.  
  14. --text follows this line--
  15. In article <4e0lp3$lkf@nic.wat.hookup.net> xenon@the-fix.sos.on.ca writes:
  16. <snip>
  17.       /* open a file for update */
  18.       stream = fopen("DUMMY.FIL", "w+");
  19.  
  20.       /* write some data to the file */
  21.       fprintf(stream, "%d %c %f", i, c, f);
  22.  
  23.       /* close the file */
  24.       fclose(stream);
  25. <snip>
  26.        This example taken out of the Borland Help library should work fine.
  27.    Yet, nothing is written to the file "dummy.fil".  although the file is
  28.  
  29. For text streams, the last character in your file should be a
  30. newline. So, change the print statement to
  31.  
  32. fprintf(stream, "%d %c %f\n", i, c, f);
  33.  
  34. I do not know why you are getting an empty file: but the C standard
  35. does not guarantee that a text file with non-newline last character
  36. can be read back by the same C program identically to as written out. 
  37.  
  38. In any case, it is a bad example to put in a help file.
  39.  
  40. Cheers
  41. Tanmoy
  42. --
  43. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  44. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  45. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  46. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  47. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  48. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  49.